<?Lassoscript
// Last modified 12/14/11 by ECL, Landmann InterActive

// FUNCTIONALITY
// This file processes action_params

// Copying Action_Params to vars
// Remove leading and trailing spaces
// If required is missing, output an error
// If multiple errors, they will step on each other, but not worried about it

// CHANGE NOTES
// 8/7/11
// First implementation.
// 12/14/11
// Adding Slider Configuration fields

// Var('svDebug' = 'Y');

If(Action_Param('Error') != '');
	Var('vError' = Action_Param('Error'));
/If;
If(Action_Param('Option') != '');
	Var('vOption' = Action_Param('Option'));
/If;
Var('vID' = Action_Param('id'));
// Copy ID to be used in Assignments
Var('vSliderGroupID' = $vID);

// Pass a param "New" through the URL to indicate it is a new page
Var('vNew' = Action_Param('New'));

Var('vProcess' = Action_Param('Process'));

Var('vsg_name' = Action_Param('sg_name'));
	$vsg_name->trim;
Var('vActive' = Action_Param('Active'));
	$vActive->trim;

// Convert Action_Params
Var('SliderTypeID' = Action_Param('SliderTypeID'));
Var('SliderTypeIDSubmit' = Action_Param('SliderTypeID'));

Local('params' = (Action_Params));
// Uncomment to see params that were submit
// ('42: Params = '+(#params)+'<br>\n');

// An array of form params to ignore for processing
Local('IgnoreParamsArray' = array('ID', 'SliderTypeID', 'sg_name', 'Active', 'Process', 'DataType', 'Action'));
// An array to put the cleaned-up params
Var('SliderConfigParamsArray' = array);
	Loop(#params->Size);
		// Don't copy Lasso operators
		If(!((#params ->get:(loop_count)->first)->(beginswith:'-')));
			// Don't copy anything in $IgnoreParamsArray
			Local('CheckThisParam' = (#params ->get:(loop_count)->first));
			If($IgnoreParamsArray->contains($CheckThisParam));
				// Do nothing
			Else;
				If($svDebug == 'Y');
				('<strong>SliderTypeIDSubmit</strong> = '+($SliderTypeIDSubmit)+'<br>\n');
					'<strong>';
					(#params->get:(loop_count)->first);
					'</strong>';
					' = ';
					(#params->get:(loop_count)->second);
					'<br>\n';
				/If;

				// Insert the param into $SliderConfigParamsArray for use later in the Update
				$SliderConfigParamsArray->insert(
				(Encode_SQL(#params->get:(loop_count)->first)) = (Encode_SQL(#params->get:(loop_count)->second))
				);

			/If;
		/If;
	/Loop;
	
	If($svDebug == 'Y');
		('<strong>slidergroup_params.inc</strong><br>\n');
		('90: Response_Filepath = '+(Response_Filepath)+'<br>\n');
		('90: vSliderGroupID = '+($vSliderGroupID)+'<br>\n');
		('90: SliderTypeID = '+($SliderTypeID)+'<br>\n');
		('90: SliderTypeIDSubmit = '+($SliderTypeIDSubmit)+'<br>\n');
		('<strong>SliderConfigParamsArray</strong> = '+($SliderConfigParamsArray)+'<br>\n');
	/If;

// If required is missing, output error 1003 "Required Missing"
// but ONLY if the page has been submit
If($vNew != 'Y');
	If(($vsg_name == '') || ($vActive == '') || ($SliderTypeID == ''));
		Var('vError' = '1003');
		Var('vOption' = 'a required field');
	/If;
/If;

// OPTIONAL FIELDS
// None

// Create name to display
Var('vDisplayName' = $vsg_name);

?>